/**
 * Copyright [2010] Delta Air Lines, Inc. All Rights Reserved Access,
 * Modification, or Use Prohibited Without Express Permission of Delta Air
 * Lines.
 */
package com.delta.rafg.core.database;


import com.delta.rafg.core.config.ConfigSettings;
import com.delta.rafg.core.exception.RAFGException;


/**
 * @author RAFG Development Team (D9127520)
 */
public interface IDataHandler {
	
	/**
	 * Sync polling frequency style. 
	 */
	enum POLL_STYLE { INTERVAL, TIMESTAMP };
	
	/**
	 * @return Style of polling for updates - Interval or timestamp.
	 */
	POLL_STYLE getPollStyle();
	
	/**
	 * @return frequency of polling as a timestamp if poll_style is timestamp.
	 * 		   frequency of polling in minutes if poll_style is interval.
	 */
	String getPollFrequency();
	
    /**
     * Add a datalistener implementation to recieve notifications of any changes
     * to this data handler.
     * @param dataListener Data listener implementation
     */
    void addDataListener(IDataListener dataListener);

    /**
     * Close and release resources used by the datasource.
     */
    void closeConnection();

    /**
     * Destroy all resources of a datahandler for the purpose of allowing it to
     * become garbage collected.
     */
    void destroy();

    /**
     * @return Tables changed since the last time this method was called.
     *         Returns null if no tables have changed.
     * @throws RAFGException RAFGException
     */
    String[] getChangedTables() throws RAFGException;

    /**
     * Get the persistent connection for this datahandler. This connection
     * is to be used for simple queries, it is maintained by the datahandler.
     * Please do not close it or turn off its autocommit.
     * @return java.sql.Connection SQL Connection
     * @throws RAFGException Thrown for internal RAFG errors.
     */
    java.sql.Connection getConnection() throws RAFGException;

    /**
     * @return DataHandlerOptions used to configure datasource
     */
    DataHandlerOptions getDataHandlerOptions();

    /**
     * @return Array of schemas being monitored by this datasource
     */
    String[] getMonitoredSchemas();

    /**
     * @return Array of tables being monitored by this datasource
     */
    String[] getMonitoredTables();

    /**
     * @param options - DataHandlerOptions to use
     * @throws RAFGException RAFGException
     */
    void initialize(DataHandlerOptions options) throws RAFGException;

    /**
     * @param dataHandlerPropertyIdentifier
     * @throws RAFGException RAFGException
     */
    void initialize(String dataHandlerPropertyIdentifier) throws RAFGException;

    void initialize(String dataHandlerPropertyIdentifier, DataHandlerOptions options) throws RAFGException;

    /**
     * @param dataHandlerPropertyIdentifier
     * @param configSettings
     * @throws RAFGException RAFGException
     */
    void initialize(String dataHandlerPropertyIdentifier,
        ConfigSettings configSettings) throws RAFGException;

    /**
     * Remove a data listener implementation from recieving notifications.
     * @param dataListener Data listener
     */
    void removeDataLister(IDataListener dataListener);
}
